package main

func findContinuousSequence2(target int) [][]int {
	ret := make([][]int, 0)
	for i := 0; i < target; {
		sum := 0
		j := i
		result := make([]int, 0)
		for ; j < target; j++ {
			sum += j
			result = append(result, j)
			if sum == target {
				ret = append(ret, result)
			}

			if sum > target {
				break
			}
		}

		i++

	}

	return ret
}

func findContinuousSequence(target int) [][]int {
	ret := make([][]int, 0)
	i := 0
	sum := 0
	temp := make([]int, 0)
	for i < target {
		i++
		sum += i
		temp = append(temp, i)

		for sum >= target {
			if sum == target {
				t := make([]int, 0)
				for k := 0; k < len(temp); k++ {
					t = append(t, temp[i])
				}

				if len(t) > 1 {
					ret = append(ret, t)
				}

				break
			}

			sum -= temp[0]
			temp = temp[1:]
		}

	}

	return ret
}

func main() {
	findContinuousSequence(9)
}
